package com.ds.lens.flink.monitor.forecast.function;

import com.ds.lens.data.common.constant.DetectionTypeEnum;
import com.ds.lens.flink.monitor.common.MonitorDefinitionFactory;
import com.ds.lens.flink.monitor.common.bo.MetricBundle;
import com.ds.lens.flink.monitor.common.bo.MonitorDefinition;
import org.apache.flink.api.common.functions.FilterFunction;

/**
 * Description:
 *
 * @author WeiShaoying
 * @date 2020-05-09
 */
public class ForecastFilter implements FilterFunction<MetricBundle> {
    private static final long serialVersionUID = -8606359796226617363L;

    @Override
    public boolean filter(MetricBundle metricBundle) throws Exception {
        MonitorDefinition definition = MonitorDefinitionFactory.get().getMonitorDefinitionByState(metricBundle.getState());
        return definition.getDetectionMethod() == DetectionTypeEnum.DYNAMIC_STATE.getCode();
    }
}
